// 开发文档: https://uniapp.dcloud.net.cn/uniCloud/cloud-obj

// 测试云对象
// 调用公共函数
const v = require('ver');
module.exports = {
    _before: function() {
        console.log('before',this.getMethodName(),this.getUniIdToken(),this.getCloudInfo(),this.getClientInfo());
        
        const methodName = this.getMethodName()
        if (methodName === 'add' && !this.getUniIdToken()) {
            throw new Error('token不存在')
        }
    },
    add(title, content) {
        console.log('title', title);
        title = title.trim()
        content = content.trim();

        if (!title || !content) {
            return {
                errCode: 'INVALID_TODO',
                errMsg: 'TODO标题或内容不可为空'
            }
        }
        // ...其他逻辑
        let msg = v(title);
        return {
            errCode: 0,
            errMsg: msg
        }
    }
}
